﻿using workflowbackend.CommonResults;
using workflowbackend.ExceptionResults;

namespace workflowbackend.CommonControllerExtensions
{
    public static class CommonControllerExtension
    {
        public static IServiceCollection AddCommonControllers(this IServiceCollection services)
        {
            services.AddControllers(option =>
            {
                // 1、配置通用结果
                option.Filters.Add<CommonResultFillter>();
                // 2、配置通用异常
                option.Filters.Add<ExceptionResultFilter>();
            }
            ).AddJsonOptions(options =>
            // 3、配置通用Json格式
            options.JsonSerializerOptions.PropertyNamingPolicy = null
            );
            return services;
        }
    }
}
